//
//  BaseTableViewController.swift
//  8.31-WH微博
//
//  Created by 吴涵 on 15/9/1.
//  Copyright © 2015年 wuhan. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController {

    /// 登陆界面
//    var login = false
    var login =  UserAccountViewModel.sharedUserAccount.userLogin
    
//    var login = UserAccount.loadUserAccount()?.access_token != nil
    var view1: WHVisitorView?
    
    override func loadView() {
//        printLog(NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).last)
        
        login ? super.loadView() : setLoginView()
    }
    
    private func setLoginView(){
/// 必须实例化才可以被其他类访问到
        view1 = WHVisitorView()
        view = view1

        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "registerButtonIsClick")
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "loginButtonIsClick")
    
        view1?.registerButton.addTarget(self, action: "registerButtonIsClick", forControlEvents: UIControlEvents.TouchUpInside)
        
        view1?.loginButton.addTarget(self, action: "loginButtonIsClick", forControlEvents: UIControlEvents.TouchUpInside)
    }
     func registerButtonIsClick(){
    
            print("注册")
    }
     func loginButtonIsClick() {

        let nav = UINavigationController(rootViewController: WHOAuthViewController())
        presentViewController(nav, animated: true, completion: nil)

        
    }
   
}
